

CONFIG_SYS_NS16550_CLK = 50000000
MODE_X_DIV = 16

# baud_div = (CONFIG_SYS_NS16550_CLK + (baudrate * (MODE_X_DIV / 2))) / (MODE_X_DIV * baudrate)
# baud_div_s = CONFIG_SYS_NS16550_CLK / MODE_X_DIV / baudrate

def simple_div(baudrate):
	baud_div = CONFIG_SYS_NS16550_CLK / MODE_X_DIV / baudrate
	return baud_div

def normal_div(baudrate):
	baud_div = (CONFIG_SYS_NS16550_CLK + (baudrate * (MODE_X_DIV / 2))) / (MODE_X_DIV * baudrate)
	return baud_div

def bauddiv_2_normalbaudrate(baud_div):
	 baudrate = CONFIG_SYS_NS16550_CLK / ((baud_div * MODE_X_DIV) - (MODE_X_DIV / 2))
	 return baudrate

def bauddiv_2_simplebaudrate(baud_div):
	baudrate = CONFIG_SYS_NS16550_CLK / MODE_X_DIV / baud_div
	return baudrate

def print_bauddiv(baudrate):
	n_div = normal_div(baudrate)
	s_div = simple_div(baudrate)

	cnn_rate = bauddiv_2_normalbaudrate(n_div)
	cns_rate = bauddiv_2_simplebaudrate(n_div)

	csn_rate = bauddiv_2_normalbaudrate(s_div)
	css_rate = bauddiv_2_simplebaudrate(s_div)

	print "baudate: %d, normal-simple div: %d-%d, -- calc rate: %d %d %d %d"%(
		baudrate, n_div, s_div, cnn_rate, cns_rate, csn_rate, css_rate)

print_bauddiv(38400)
print_bauddiv(115200)
print_bauddiv(230400)
print_bauddiv(460800)
print_bauddiv(921600)
print_bauddiv(1152000)
print_bauddiv(3125000)

# for i in xrange(250000, 230400, -100):
# 	print print_bauddiv(i)	
# print_bauddiv(250000)

# baudrate = 38400
# baudrate = 115200
# baudrate = 921600
# baudrate = 230400
# baudrate = 460800


# print baud_div
# print baud_div & 0xff
# print baud_div >> 8

# print baud_div_s
# print baud_div_s & 0xff
# print baud_div_s >> 8

# baud_div = baud_div_s

# baud_div = 13
# n_baudrate = CONFIG_SYS_NS16550_CLK / ((baud_div * MODE_X_DIV) - (MODE_X_DIV / 2))

# print n_baudrate


# cycle/f=time
# 998396/f t/s = s
# f=cycle/time
# cycle=time*f

cycle = 998396
time = 3074
f = 1000
# f=500

print "f:", cycle/time
print "time:", cycle/f
print "cycle:", time*f

size=712496
print float(size)*2/10000

print cycle/float(50*1000*1000)



a = [3, 1, 2]
print a
a.sort()
print a
a.reverse()
print a

index = 10
indexs = [  i for i in xrange(index, max(0, index-10), -1)  ]


print indexs


print type(indexs) == list

print indexs < 0


a = [1, 1, 5, 2, 3, 4, 4]
b = set(a)
print a
print b

for i in b:
	print i


import re
ld_reg_pten = re.compile("^(?i)([\w]+_EL[\d]*)$")

r = "SPSR_EL1"

print ld_reg_pten.match("ESR_EL1")
print ld_reg_pten.match("SPSR_EL1")
print ld_reg_pten.match("ELR_EL1")
print ld_reg_pten.match(r)


print re.match("^r", "arrrr")


a=[1,3]
b=[2,4]
print a+b

print re.match("^(?i)[^bcmsr\s]", "\n fSstr")
print re.match("^(?i)(([^idbcmrles\s])|(s[^t]))", "fcscc")

print ord('-')
for i in xrange(0, 70, 1):
	print "%d: %c"%(i, i)
print "%c"%45


r = re.compile("(?i)(.+_el\d|.*ffr.*)")
print r.match("sp_el1")
print r.match("ffr")


a="123456"

print a[1:10]

s = '800010bfc0bfd1808000107cc1bcd27d8000107cc1bcd27d8000107cc1bcd1f7'
    # 'd8000107cc1bcd27d8000107cc1bcd1f 800010bfc0bfd1808000107cc1bcd27'

for i in xrange(0, -len(s), -32):
	if i == 0:
		print s[i-32:],
	else:
		print s[i-32:i],

print
for i in xrange(0, len(s), 32):
	print s[i:i+32],